class Solution:
    def plusOne(self, digits: list[int]) -> list[int]:
        digits = [0] + digits
        n = len(digits)
        digits[n-1] += 1
        for i in range(n-1, 0, -1):
            if digits[i] != 10:
                break
            else:
                digits[i-1] += 1
                digits[i] = 0
        
        if digits[0] == 0:
            return digits[1:]
        else:
            return digits


sol = Solution()

digits =[9, 9]
sol.plusOne(digits)